package com.orange.eduservice.controller.front;

import com.orange.commonutils.result.Result;
import com.orange.eduservice.entity.EduCourse;
import com.orange.eduservice.entity.EduTeacher;
import com.orange.eduservice.service.EduCourseService;
import com.orange.eduservice.service.EduTeacherService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author orange
 * @email orangestart@yeah.net
 * @create 2021-12-23 20:59
 * 首页显示课程名师数据
 */
@RestController
@CrossOrigin
@Api(tags = "首页显示课程名师数据")
@RequestMapping("/eduService/indexFront")
public class IndexFrontController {

    @Autowired
    private EduCourseService eduCourseService;

    @Autowired
    private EduTeacherService eduTeacherService;

    //查询前8条热门课程，查询前4个名师
    @GetMapping("/index")
    public Result index() {

        //调用查询前8热门课程的方法
        List<EduCourse> courseList = eduCourseService.selectHotCourse();
        //查询前4张热门讲师
        List<EduTeacher> teacherList = eduTeacherService.selectHotTeacher();

        return Result.ok().data("courseList", courseList).data("teacherList", teacherList);
    }

}
